﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;

namespace DragDraw.Service
{
    public class ErrorManager
    {
        private static ErrorManager m_instance = new ErrorManager();
        public static ErrorManager Instance { get { return m_instance; } }

        private string m_path;

        private static bool IS_LOG_ENABLE = true;

        private ErrorManager()
        {
            m_path = ServerUtils.GetLocalPath("log.txt");
            if (!File.Exists(m_path))
            {
                using (FileStream fs = File.Create(m_path))
                {
                }
            }
        }

        public void LogMessage(string text)
        {
            if (IS_LOG_ENABLE)
            {
                StreamWriter sw = null;
                try
                {
                    sw = File.AppendText(m_path);
                    sw.WriteLine(text);
                }
                catch
                {
                }
                finally
                {
                    if (sw != null)
                        sw.Close();
                }
            }
        }
    }
}
